package com.isdepci.project.gasEmission.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.gasEmission.domain.WasteWater;
import com.isdepci.project.gasEmission.service.IWasteWaterService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 废弃物和水Controller
 *
 * @author isdepci
 * @date 2023-09-01
 */
@RestController
@RequestMapping("/wasteWater/wasteWater")
public class WasteWaterController extends BaseController
{
    @Autowired
    private IWasteWaterService wasteWaterService;

    /**
     * 查询废弃物和水列表
     */
    @PreAuthorize("@ss.hasPermi('wasteWater:wasteWater:list')")
    @GetMapping("/list")
    public TableDataInfo list(WasteWater wasteWater)
    {
        startPage();
        List<WasteWater> list = wasteWaterService.selectWasteWaterList(wasteWater);
        return getDataTable(list);
    }

    /**
     * 导出废弃物和水列表
     */
    @PreAuthorize("@ss.hasPermi('wasteWater:wasteWater:export')")
    @Log(title = "废弃物和水", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WasteWater wasteWater)
    {
        List<WasteWater> list = wasteWaterService.selectWasteWaterList(wasteWater);
        ExcelUtil<WasteWater> util = new ExcelUtil<WasteWater>(WasteWater.class);
        return util.exportExcel(list, "wasteWater");
    }

    /**
     * 获取废弃物和水详细信息
     */
    @PreAuthorize("@ss.hasPermi('wasteWater:wasteWater:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wasteWaterService.selectWasteWaterById(id));
    }

    /**
     * 新增废弃物和水
     */
    @PreAuthorize("@ss.hasPermi('wasteWater:wasteWater:add')")
    @Log(title = "废弃物和水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WasteWater wasteWater)
    {
        return toAjax(wasteWaterService.insertWasteWater(wasteWater));
    }

    /**
     * 修改废弃物和水
     */
    @PreAuthorize("@ss.hasPermi('wasteWater:wasteWater:edit')")
    @Log(title = "废弃物和水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WasteWater wasteWater)
    {
        return toAjax(wasteWaterService.updateWasteWater(wasteWater));
    }

    /**
     * 删除废弃物和水
     */
    @PreAuthorize("@ss.hasPermi('wasteWater:wasteWater:remove')")
    @Log(title = "废弃物和水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wasteWaterService.deleteWasteWaterByIds(ids));
    }
}
